package com.lty.packet.server;

import org.jboss.netty.buffer.ChannelBuffer;
import org.jboss.netty.channel.ChannelHandlerContext;
import org.jboss.netty.channel.MessageEvent;
import org.jboss.netty.channel.SimpleChannelHandler;

public class HelloHandler extends SimpleChannelHandler {
	//Handler是线程安全的，不会有并发问题
	private int count = 1;

	@Override
	public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception {
		
		//解决分包粘包
//		System.out.println(e.getMessage() + "  " +count);
//		count++;
		
		//分包粘包问题
		ChannelBuffer buffer = (ChannelBuffer) e.getMessage();
		byte[] bytes = buffer.array();
		System.out.println(new String(bytes));
	}
}
